﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace FigureDraw
{
    public class ProcessSymbolDataFlow : ProcessSymbol
    {
        public ProcessSymbolDataFlow(StorageDevice sd)
            : base(sd)
        {
            this.strInfor = "Process";
        }

        public ProcessSymbolDataFlow(StorageDevice sd, Infor infor)
            : base(sd, infor)
        {
            
        }

        public override void DrawToDevice(Form form)
        {
            this.R = 255;
            this.G = 0;
            this.B = 0;
            this.LineWidth = 5;
            this.KhoiTaoTruocKhiVe();


            this.EndPoint = new Point(this.BeginPoint.X + 120, this.BeginPoint.Y + 80);
            int width = EndPoint.X - BeginPoint.X;
            int height = EndPoint.Y - BeginPoint.Y;
            int centreX = (BeginPoint.X + EndPoint.X) / 2;
            int centreY = (BeginPoint.Y + EndPoint.Y) / 2;


            Point dt = new Point();
            dt.X = width / 5;
            dt.Y = height / 5;
            float fontSize = fontSize = (float)(height - height / 2 - height / 4);
            if (fontSize < 1)
                fontSize = 1;

            this.rtbInfor.ReadOnly = false;
            this.rtbInfor.Font = new Font("Arial", 12, FontStyle.Bold);
            this.rtbInfor.BorderStyle = BorderStyle.None;
            this.rtbInfor.Text = this.strInfor;
            this.rtbInfor.BackColor = System.Drawing.SystemColors.Menu;
            this.rtbInfor.SelectionAlignment = HorizontalAlignment.Center;
            this.rtbInfor.Location = new Point(BeginPoint.X + dt.X + 1, BeginPoint.Y + dt.Y + 1);
            this.rtbInfor.Size = new System.Drawing.Size(width - 2 * (dt.X + 1), height - 2 * (dt.Y + 1));
            this.rtbInfor.Visible = true;
            if (form != null)
                form.Controls.Add(this.rtbInfor);
            else
                this.StorageDevice.drawString(this.rtbInfor.Text, this.rtbInfor.Font, this.rtbInfor.Location);


            this.StorageDevice.drawEllipse(centreX, centreY, width, height);
        }
    }
}
